Repository navigation
SVG: apply CSS rules with a universal or element selector - #2181
Open
RavSinghChandan wants to merge 5 commits into
Open
RavSinghChandan wants to merge 5 commits into
RavSinghChandan wants to merge 5 commits into
Conversation
Only .class rules were read from a <style>, so * { ... } and rect { ... }
were dropped; every matplotlib SVG starts with
*{stroke-linejoin: round; stroke-linecap: butt}. _extract_css_rules()
now returns every rule, _extract_css_class_styles() keeps the class
ones, and the * and element rules apply before class rules, as CSS
specificity orders them.
The sample is a matplotlib figure whose <style> holds
*{stroke-linejoin: round; stroke-linecap: butt}; only the line join of
its strokes changes, every coordinate is the same.
# Conflicts: # CHANGELOG.md # fpdf/svg.py
andersonhc
approved these changes
Nov 13, 2026
# Conflicts: # CHANGELOG.md
# Conflicts: # CHANGELOG.md
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Only
.classrules are read from a<style>, so* { ... }andrect { ... }are dropped. Every SVG that matplotlib writes starts with:_extract_css_rules()now returns every rule,_extract_css_class_styles()keeps the class ones from it, and rules for*and element names are kept incss_type_styles._style_map_for()applies them before class rules and inline styles, in the order of CSS specificity.test_svg_css_type_and_universal_selectorscovers the cascade against attributes, inline styles and class rules;test_svg_css_universal_selector_of_matplotlibcovers the matplotlib rule.path_clippingpath.svgis a matplotlib figure with that rule, so its reference PDF is regenerated: its strokes get round joins, and every coordinate stays the same.